<?php
//------------------------------------------------------
// page archivage d'une mission
//------------------------------------------------------

// ajout des librairies
include ("../cgi-bin/global.inc.php");
include ("fonctions.php");

	
$date=date("Y-m-d H:i");
$sql = "SELECT id from missions WHERE year(missions.date_archive) <> '0000'";
$rsql = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql<br>sql = ".$sql);
while($table_liste = mysql_fetch_object($rsql))	
	{
        $sql = "SELECT DateAudit FROM missions_etablissement WHERE missionsid=$table_liste->id AND year(DateAudit) <> '0000' AND missions_etablissement.actif=1 ORDER BY DateAudit asc "; 
	$rsql2 = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql<br>sql = ".$sql);
	if (mysql_num_rows($rsql2) <> 0) $table_liste2 = mysql_fetch_object($rsql2);
	$sql = "update missions set termine=1,date_audit='$table_liste2->DateAudit' WHERE id=$table_liste->id "; 
	$resultat = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql<br>sql = ".$sql);
	}
?>
